/*
 * @Descripttion:
 * @version: 1.0
 * @Author: 张泽涛
 * @LastEditors: 张泽涛
 * @LastEditTime: 2021-02-24 19:52:53
 */
import createRoute from '../utils/route'
export default class History {
  constructor (router) {
    this.router = router
    this.current = createRoute(null, '/')
    this.cb = null
  }

  transitionTo (path, onComplete) {
    //   route --> {path: '',matched: []}
    this.current = this.router.matcher.match(path)
    this.cb && this.cb(this.current)
    onComplete && onComplete()
  }

  listen (cb) {
    this.cb = cb
  }
}
